import { defineStore } from 'pinia'

export const usePermissionStore = defineStore('permission', {
  state: () => ({
    role: '',
    permissions: []
  }),
  
  getters: {
    isAdmin: (state) => state.role === 'admin',
    hasPermission: (state) => (permission) => state.permissions.includes(permission)
  },
  
  actions: {
    setRole(role) {
      this.role = role
    },
    setPermissions(permissions) {
      this.permissions = permissions
    }
  }
})
